<?php

//Lưu xuống csdl đã học từ vựng
$idLesson = $_SESSION['idLesson'];
$IDUserOnline = elgg_get_logged_in_user_guid();

$lesson = new Lesson();
////--------------Xu Ly Load Lai bai viet khi da viet bai--------------////
$write =  new Write();
$write = $write->GetWrite($IDUserOnline, $idLesson);
if($write->IDLesson == null)
{
    $write->SaveWrite($IDUserOnline, $idLesson, "");
}
else
{
    $_SESSION['myWriteContent'] = $write->Content;
}

////--------------End Xu Ly Load Lai bai viet khi da viet bai--------------////



$lesson = $lesson->getSubjectWritingByIDLesson($idLesson);
$_SESSION["subjectWriting"] = $lesson->SubjectWriting;

if ($lesson != false) {
    system_message("Going to Writing");

    forward(elgg_get_site_url() . "MyCourse/write");
} else {
    register_error("can not going to Writing");
    forward(REFERER); // REFERER is a global variable that defines the previous page
}
?>
    

